function [ squaredChi ] = squaredChiTest( nums, cantCells )
%UNTITLED2 Summary of this function goes here
%   Detailed explanation goes here

    [freq, x] = hist(nums, cantCells);
    cellSize = (max(nums) - min(nums)) * length(nums) / cantCells;
    estimatedFreq = length(nums) / cantCells;
    
    squaredChi = 0;
    for i=1:cantCells
        estimatedFreq(i) = myDensityFunction(x(i)) * cellSize;
        squaredChi = squaredChi + ((freq(i) - estimatedFreq(i))^2) / estimatedFreq(i);
        fprintf('$%2d$ & $%9.3f$ & $%9.3f$ & $%9.3f$ & $%9.3f$ & $%9.3f$\\\\\n', i, freq(i), estimatedFreq(i), ...
            freq(i) - estimatedFreq(i), (freq(i) - estimatedFreq(i))^2, ...
            ((freq(i) - estimatedFreq(i))^2) / estimatedFreq(i));
    end
end